<template>
	<view id="header-back">
    <view class="shops-header-box">
			<view class="shops-header">
				<view class="shops-left" @click="toBack('')">
					<image  src="/static/icon/arrow_left_01.png" class="arrow-l" mode=""></image>
					<view class="shops-header-title">{{headerTitle}}</view>
				</view>
				<view class="shops-right" @click="toBack('/pages/index/index/index')">
					<image src="/static/icon/home_icon_02.png" class="home-icon" mode=""></image>
					<view class="to-home">{{ $lang('common.backHome') }}</view>
				</view>				
			</view>
		</view>
	</view>
</template>

<script>
export default {
	name: 'headerBack',
	props: {
		headerTitle: {
			type: String,
			default: '',
		}
	},
	data() {
		return {
			curRoute: '',
		};
	},
	mounted(){
    document.getElementsByTagName("title")[0].innerText = this.headerTitle;
	},
	onLoad() {

	},
	components: {

	},
	onShow() {
		
	},
	methods: {
		// 获取当前路由
		getPages(){
			let routes = getCurrentPages(); // 获取当前打开过的页面路由数组
			return routes[routes.length - 1].route //获取当前页面路由
		},
		// 跳转路由
		toBack(url){
			let routes = getCurrentPages();
			// console.log(url)
			if(url){
				uni.reLaunch({
					url: url,
				})
			}else {
				if(routes.length == 1){
					url = url ? url : '/pages/index/index/index'
					uni.reLaunch({
						url: url,
					})
				}else {
					uni.navigateBack({
						delta: 1,
					})					
				}				
			}
		},
		
	}
};
</script>

<style scoped lang="scss">
	#header-back {
		height: 88rpx;

	}
	.shops-header-box {
		width: 100%;
		height: 88rpx;
		background: #fff;
		position: fixed;
		top: 0px;
		left: 0px;
		z-index: 111;
		padding: 0px 32rpx;
		box-sizing: border-box;
		.shops-header {
			width: 100%;
			height: 88rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			.shops-left {
        width: calc(100% - 160upx);
				display: flex;
				align-items: center;
				.shops-header-title {
          width: calc(100% - 60upx);
          text-wrap: normal;
          overflow: hidden;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
					font-size: 36rpx;
					font-family: PingFangSC-Semibold, PingFang SC;
					font-weight: 600;
					color: #292929;
					line-height: 50rpx;
					margin-left: 6rpx;
				}
			}
			.shops-right {
        width: 160upx;
				display: flex;
				align-items: center;
				.home-icon {
					width: 32rpx;
					height: 32rpx;
					margin-right: 12rpx;
				}
				.to-home {
					font-size: 26rpx;
					color: #31bb6d;
				}
			}
		}	
	}
</style>
